Skip to content

feat(@angular/build): support runtime Zone.js detection in Vitest unit test runner#32492

Merged
clydin merged 1 commit intoangular:mainfrom
clydin:vitest/dynamic-zonejs-inclusion
Mar 2, 2026
Merged

feat(@angular/build): support runtime Zone.js detection in Vitest unit test runner#32492
clydin merged 1 commit intoangular:mainfrom
clydin:vitest/dynamic-zonejs-inclusion

Conversation

@clydin
Copy link
Member

@clydin clydin commented Feb 13, 2026

This commit improves how the Vitest unit test runner handles Zone.js and its testing polyfills. Previously, the inclusion of provideZoneChangeDetection and zone.js/testing was determined solely by a build-time check for zone.js in the polyfills array.

Now, the runner supports three strategies for zone.js/testing inclusion:

  • none: If zone.js is not installed in the project.
  • static: If zone.js is explicitly included in the polyfills build option.
  • dynamic: If zone.js is installed but not explicitly in polyfills. This uses a runtime check and dynamic import to load testing support if Zone is present.

Additionally, TestBed initialization now dynamically provides ZoneChangeDetection based on the runtime presence of Zone.js, better supporting zoneless applications and implicit Zone.js loading scenarios.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/build labels Feb 13, 2026
@clydin clydin force-pushed the vitest/dynamic-zonejs-inclusion branch 2 times, most recently from 7e654f5 to 53cc74d Compare February 18, 2026 19:25
@clydin clydin marked this pull request as ready for review February 27, 2026 00:43
@clydin clydin added target: major This PR is targeted for the next major release action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 27, 2026
@clydin clydin requested a review from alan-agius4 February 27, 2026 00:43
…t test runner

This commit improves how the Vitest unit test runner handles Zone.js and its testing polyfills.
Previously, the inclusion of provideZoneChangeDetection and zone.js/testing was determined solely by a build-time check for zone.js in the polyfills array.

Now, the runner supports three strategies for zone.js/testing inclusion:
- none: If zone.js is not installed in the project.
- static: If zone.js is explicitly included in the polyfills build option.
- dynamic: If zone.js is installed but not explicitly in polyfills. This uses a runtime check and dynamic import to load testing support if Zone is present.

Additionally, TestBed initialization now dynamically provides ZoneChangeDetection based on the runtime presence of Zone.js, better supporting zoneless applications and implicit Zone.js loading scenarios.
@clydin clydin force-pushed the vitest/dynamic-zonejs-inclusion branch from 53cc74d to af37845 Compare March 2, 2026 15:06
@clydin clydin requested a review from alan-agius4 March 2, 2026 15:06
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 2, 2026
@clydin clydin merged commit 414320d into angular:main Mar 2, 2026
35 checks passed
@clydin
Copy link
Member Author

clydin commented Mar 2, 2026

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the vitest/dynamic-zonejs-inclusion branch March 2, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build detected: feature PR contains a feature commit target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants